package com.sinosoft.front;

import java.net.MalformedURLException;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.log4j.Logger;

import com.sinosoft.front.dto.common.xsd.IinsuranceExtensionEhm;
import com.sinosoft.front.dto.common.xsd.TxInsuranceRequestEhm;
import com.sinosoft.front.dto.common.xsd.TxInsuranceRequestExtensionEhm;
import com.sinosoft.front.dto.vehicleModelQuery.out.xsd.VehicleModelData;
import com.sinosoft.front.dto.xsd.VehicleModelQueryRequest;
import com.sinosoft.front.dto.xsd.VehicleModelQueryResponse;
import com.sinosoft.front.service.VehicleModelQueryServicePortType;
import com.sinosoft.front.service.VehicleModelQueryServicePortTypeProxy;


public class VehicleModelQueryTest {
	
	static Logger logger = Logger.getLogger(VehicleModelQueryTest.class);
	public static void main(String[] args) throws RemoteException, ServiceException, MalformedURLException {
		//调用服务器端方法
		VehicleModelQueryServicePortTypeProxy proxy = new VehicleModelQueryServicePortTypeProxy();
		proxy.setEndpoint("http://proxy.tuxing51.com/frontServiceCenter/services/VehicleModelQueryService?wsdl");
		VehicleModelQueryServicePortType portType = proxy.getVehicleModelQueryServicePortType();
		
		
		//请求头信息
		VehicleModelQueryRequest request = new VehicleModelQueryRequest();
		TxInsuranceRequestEhm requestEhm = new TxInsuranceRequestEhm();
		requestEhm.setTransExeDate("这个是日期");
		requestEhm.setTransExeTime("这个是时间");
		request.setTxInsuranceRequestEhm(requestEhm);
		
		requestEhm.setIinsuranceExtensionEhm(new IinsuranceExtensionEhm());
		logger.info("====车型查询服务====");
		//请求头数据
		TxInsuranceRequestExtensionEhm extensionEhm = new TxInsuranceRequestExtensionEhm();
		extensionEhm.setOperator("HN1_Test");
		extensionEhm.setOperatorKey("123456");
		request.setTxInsuranceRequestExtensionEhm(extensionEhm );
		//PlatModelCode
		
		//入口参数
		request.setPolicySort("HN1");
		//request.setAgentCode("410511198203181755");
		//request.setFranchiserCode("4105979018");
		//request.setLocalModelQueryFlag("1");
		//request.setStandardName("B");
		request.setCityAreaCode("410500");
		//request.setBrandName("起亚");//BRWARAUC0001
		request.setStandardName("奥迪FV7201BACWG轿车");
		//request.setFrameNo("LSVGY26R0F2159877");
		//request.setModelCode("RWAACD0013");
		logger.info("传入参数：");
		logger.info("系统来源:"+request.getPolicySort()+",车架号:"+request.getCityAreaCode()+",城市代码:"+request.getCityAreaCode()+",车型名称:"+request.getBrandName());
//		ProvisonalStatusQueryService service=new ProvisonalStatusQueryServiceLocator();
//		java.net.URL url = new java.net.URL("http://proxy.tuxing51.com/frontServiceCenter/services/ProvisonalStatusQueryService?wsdl");
//		ProvisonalStatusQueryServiceSoap11BindingStub stub = new ProvisonalStatusQueryServiceSoap11BindingStub(url, service);
//		ProvisonalStatusResponse response = stub.queryProvisonalStatus(request);
		
		logger.info("返回内容：");
		VehicleModelQueryResponse response = portType.queryVehicleModel(request);
		System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getResultCode());
		logger.info("返回码："+response.getTxInsuranceResponseEhm().getTransResultEhm().getResultCode());
		System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getResultInfoDesc());
		logger.info("返回信息："+response.getTxInsuranceResponseEhm().getTransResultEhm().getResultInfoDesc());
		System.out.println(response.getTxInsuranceResponseEhm().getTransResultEhm().getErrorNo());
		logger.info("返回错误代码："+response.getTxInsuranceResponseEhm().getTransResultEhm().getErrorNo());
		//获取返回信息
		VehicleModelData[] vehicleModelDataArr = response.getVehicleModelDataArr();
		for (VehicleModelData vehicleModelData : vehicleModelDataArr) {
			System.out.println("邮箱："+vehicleModelData.getFuleType());
			
			logger.info("返回对象："+vehicleModelData);
		}

		for (VehicleModelData vehicleModelData : vehicleModelDataArr) {
			System.out.println(vehicleModelData.getStandardName());
			System.out.println("精友车型名称："+vehicleModelData.getStandardName());
			System.out.println("精友车型代码："+vehicleModelData.getModelCode());
			
			System.out.println("行业车型名称："+vehicleModelData.getPlatModelName());
			System.out.println("行业车型代码："+vehicleModelData.getPlatModelCode())
			;
			System.out.println("新车购置价："+vehicleModelData.getPurchasePrice());
			System.out.println("核定载客量："+vehicleModelData.getTonCount());
			System.out.println("核定载质量："+vehicleModelData.getTonCount());
			System.out.println("整备质量："+vehicleModelData.getVehicleWeight());
			System.out.println("排量："+vehicleModelData.getExhaustScale());
			System.out.println("燃料种类："+vehicleModelData.getFuleType());
			System.out.println("车辆产地："+vehicleModelData.getImportFlag());
			System.out.println("-------------------------------------------");
//			logger.info(vehicleModelData.getStandardName());
//			logger.info("精友车型名称："+vehicleModelData.getStandardName());
//			logger.info("精友车型代码："+vehicleModelData.getModelCode());
//			logger.info("行业车型名称："+vehicleModelData.getPlatModelName());
//			logger.info("行业车型代码："+vehicleModelData.getPlatModelCode());
//			logger.info("新车购置价："+vehicleModelData.getPurchasePrice());
//			logger.info("核定载客量："+vehicleModelData.getTonCount());
//			logger.info("核定载质量："+vehicleModelData.getTonCount());
//			logger.info("整备质量："+vehicleModelData.getVehicleWeight());
//			logger.info("排量："+vehicleModelData.getExhaustScale());
//			logger.info("燃料种类："+vehicleModelData.getFuleType());
//			logger.info("车辆产地："+vehicleModelData.getImportFlag());
			

			
		}
	
		logger.info("-------------------------------------------");
		System.out.println(vehicleModelDataArr.length);
		
		

	}

}